;
(function() {

	var skill = {
		_getGoodsArgsMapIdList: function() {
			var goods_args_map_list = this.goods_args_map_list;
			if (!Array.isArray(goods_args_map_list)) {
				goods_args_map_list = this.goods_args_map_list = [];
				this.save();
			}
			return goods_args_map_list;
		},
		_getGoodsArgsMap: function(goods_args_map_id) {
			var goods_args_map_list = this._getGoodsArgsMapIdList();
			if (goods_args_map_list.indexOf(goods_args_map_id) === -1) {
				throwCusError("商品属性表不属于指定商家")
			}
			var goods_args_map = GoodsArgsMapCon.get(goods_args_map_id);
			if (!goods_args_map) {
				throwCusError("找不到指定商品属性表")
			}
			return goods_args_map;
		},
		getGoodsArgsMapList: function(num, page) {
			var goods_args_map_list = this._getGoodsArgsMapIdList();
			goods_args_map_list = data_cut.page(goods_args_map_list, num, page);
			goods_args_map_list = goods_args_map_list.map(function(goods_args_map_id) {
				return GoodsArgsMapCon.get(goods_args_map_id);
			});
			return goods_args_map_list;
		},
		addGoodsArgsMap: function(goods_args_map_info) {
			var goods_args_map_list = this._getGoodsArgsMapIdList();
			goods_args_map_info.bus_id = this._id;
			var goods_args_map = new GoodsArgsMapCon(goods_args_map_info);
			var goods_args_map_id = goods_args_map._id
			goods_args_map_list.unshift(goods_args_map_id);
			this.save();
			return goods_args_map;
		},
		updateGoodsArgsMap: function(goods_args_map_id, goods_args_map_info) {
			var goods_args_map = this._getGoodsArgsMap(goods_args_map_id);
			goods_args_map.setInfo(goods_args_map_info);
			return goods_args_map;
		},
		removeGoodsArgsMap: function(goods_args_map_id) {
			var goods_args_map = this._getGoodsArgsMap(goods_args_map_id);
			this.goods_args_map_list = $Array.remove(this.goods_args_map_list, goods_args_map._id);
			goods_args_map.destroy();
			this.save();
		},

	};
	module.exports = skill;
	var db = require("../db/index");
	var GoodsArgsMapCon = require("../goods_args_map/_con");
	var DomainCon = require("../domain/_con");
	var GoodsCon = require("../goods/_con");
	var UserCon = require("../../core/user/_con");
	var BusCon = require("../../core/bus/_con");
	var AchCon = require("../ach/_con");
	var ClassifyCon = require("../bus.classify/_con");
	var TagCon = require("../bus.tag/_con");
	var LeagueCon = require("../league/_con");
	var BuffCon = require("../buff/_con");
	var BusUserBindCon = require("../bus_user_bind/_con");
	var BusGuideCon = require("../bus.guide/_con");
	var CommentCon = require("../comment/_con");
	var config = require("../_include/config");
	var data_cut = require("../_include/data_cut");
	var helper = require("../_include/helper");
	var md5 = require("../_include/md5");
	var $Object = require("../_include/$.Object");
	var $Array = require("../_include/$.Array");
	var tld = require('tldjs');
	var fs = require("fs");
	var Fiber = require('fibers');
}());